package design.p11_composite;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: Java
 * @description:
 * @author: zxf
 * @create: 2021-06-18 18:41
 **/
public class TreeNode <T>{

    private T name;
    private TreeNode<T> parent;
    private List<TreeNode<T>> children = new ArrayList<>();

    public TreeNode(T name){
        this.name = name;
    }

    public T getName() {
        return name;
    }

    public void setName(T name) {
        this.name = name;
    }

    public TreeNode getParent(){
        return parent;
    }
    public void setParent(TreeNode<T> node){
        this.parent = node;
    }
    public List<TreeNode<T>> getChildren(){
        return children;
    }
    public void add(TreeNode<T> node){
        children.add(node);
    }
    public void remove(TreeNode<T> node){
        children.remove(node);

    }
}

//使用场景：将多个对象组合在一起进行操作，常用于表示树形结构中，例如二叉树，数等。